<!--头部公共部分-->
{include file="common/header" /}
<div style="padding:5px;">
    <fieldset class="layui-elem-field layui-field-title">
    </fieldset>
    <h2 style="text-align: center;margin-top: 10px;">您当前登录的组织架构为超级管理员</h2>
    <div style="text-align: center;margin-top: 10px;">请选择集团！</div>
    <form class="layui-form" style="text-align: center;margin-top: 10px;">
        <div class="layui-input-inline">
            <select name="company_id" lay-search="" lay-verify="required">
                <option value="">请选择集团</option>
                {volist name="company" id="v"}
                <option value="{$v.id}">{$v['company_name']}</option>
                {/volist}
            </select>
        </div>
    <fieldset class="layui-elem-field layui-field-title">
    </fieldset>
    <div style="text-align: center;margin-top: 10px;">
        <input class="layui-btn layui-btn-normal" lay-submit lay-filter="form" value="确定" readonly>
    </div>
    </form>
</div>
<!--底部公共部分-->
{include file="common/footer" /}
<script>
    layui.use(['element', 'jquery', 'form', 'laydate', 'layer'], function () {
        let $ = layui.$,
            layer = layui.layer,
            element = layui.element,
            form = layui.form;

        //监听提交
        form.on('submit(form)', function (data) {
            console.log(data);
            //发异步，把数据提交给php
            let field = data.field;
            let isLoad;
            $.ajax({
                url: '{:url("Auth/company")}',
                method: "post",
                data: field,
                success: function (result) {
                    if (result.code === 1) {
                        let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                        parent.layer.open({
                            type: 2,
                            title: '新增用户组',
                            shadeClose: true,
                            shade: 0.8,
                            area: ['55%', '50%'],
                            content: result.url
                        });
                    }
                },
                complete: function () {
                    layer.close(isLoad)
                },
                error: function (error) {
                    console.log(error)
                }
            });
        });
    });
</script>
